package com.preguicoso.client.backend.pedidos.confirmarMesa;

import java.util.ArrayList;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.Widget;
import com.preguicoso.client.checkout.CheckoutService;
import com.preguicoso.client.checkout.CheckoutServiceAsync;
import com.preguicoso.shared.entities.MesaBean;

public class ConfirmarMesa extends Composite{

	private static ConfirmarMesaUiBinder uiBinder = GWT
			.create(ConfirmarMesaUiBinder.class);

	interface ConfirmarMesaUiBinder extends UiBinder<Widget, ConfirmarMesa> {
	}
	
	@UiField
	HTMLPanel painel;
	private final CheckoutServiceAsync checkoutService = GWT
			.create(CheckoutService.class);

	public ConfirmarMesa(Long idEstabelecimento) {
		initWidget(uiBinder.createAndBindUi(this));
		checkoutService.getListMesaNaoConfirmadas(idEstabelecimento, new AsyncCallback<ArrayList<MesaBean>>() {
			
			@Override
			public void onSuccess(ArrayList<MesaBean> result) {
				Window.alert(result.size()+"");
				for (MesaBean mesaBean : result) {
					painel.add(new ConfirmarMesaItem(mesaBean));
				}
			}
			@Override
			public void onFailure(Throwable caught) {
				// TODO Auto-generated method stub
				
			}
		});
	}


}
